package hot100;

import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

public class Solution46 {
    List<List<Integer>> ans = new LinkedList<>();
    public List<List<Integer>> permute(int[] nums) {
        List<int[]> ints = Collections.singletonList(nums);
        List<Integer> collect = Arrays.stream(nums).boxed().collect(Collectors.toList());
        dfs(new LinkedList<>(), collect);
        return ans;
    }

    private void dfs(List<Integer> list, List<Integer> left) {
        if (left == null || left.size() == 0) {
            ans.add(list);
            return;
        }
        for (int i = 0; i < left.size(); i++) {
            List<Integer> input1 = new LinkedList<>(list);
            input1.add(left.get(i));
            List<Integer> input2 = new LinkedList<>(left);
            input2.remove(i);
            dfs(input1, input2);
        }
    }

    public static void main(String[] args) {
        Solution46 solution46 = new Solution46();
        List<List<Integer>> permute = solution46.permute(new int[]{1, 2, 3});

    }
}
